﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net;
using System.Web.Routing;

namespace AP.Web.Common
{
    public class ApWebHandleErrorAttribute : HandleErrorAttribute
    {

        public override void OnException(ExceptionContext filterContext)
        {
            Exception ex = filterContext.Exception;
            if (ex is WebException)
            {
                // 表示异常已处理，直接跳到500显示错误消息
                filterContext.ExceptionHandled = true;
                filterContext.Result = new RedirectToRouteResult("500", new RouteValueDictionary(new
                {
                    message = ex.Message
                }));
            }
            else
            {

            }
        }

    }
}